use nlsy.dta, clear


/// Predicting Liquidity Constraints Based on Bank Branch Closures 
// for Table 6

do predicting_lconstf.do


// Linear Probability Model of Borrower-Saver vs. Savers
// for Table 5

	capture drop sdvoly*
	capture drop rnw_s*
	capture drop dur_c_s 
	capture drop ghpi_cs_s
	capture drop afqtn_s
	
		egen sdvoly_r = std(lconstf)  // standardizing liquidity constraints measure
		egen sdvoly_pr = std(plconstf)  // standardazing predicted liquidity constraints measure
		egen sdvoly = std(job_shock)  // standardizing income volatility measure
		egen rnw_s=std(rnw) // standardizing wealth measure
		egen dur_c_s=std(dur_c) // standardizing change in county unemployment measure
		egen ghpi_cs_s = std(ghpi_cs) // standardizing growth in HPI measure
		egen afqtn_s=std(afqtn) // standardizing AFqT measure

		label var sdvoly_r "Credit Access Risk"
		label var sdvoly_pr "Credit Access Risk"
		label var sdvoly "Job Shock"
		label var rnw_s "Net Worth"
		label var dur_c_s "Change in Unemployment Rate, County"
		label var ghpi_cs_s "HPI Growth Rate, County"

local controls0 "i.age presentbias highdiscount riskaverse b1.gender b3.race i.year married haskids afqtn_s  collegemore finqa finka"
local controls3a "rnw_s ho_* w*debt"
local controls2 "sdvoly dur_c_s ghpi_cs_s"
local controls15 "sdvoly_r"
local controls15p "sdvoly_pr"


est clear

capture drop sample
reghdfe ps `controls0' `controls3a' `controls15p' `controls2' , cluster(case) absorb(state age)  keepsingletons 
gen samplem=e(sample)


	capture drop sdvoly*
	capture drop rnw_s*
	capture drop afqtn_s
	capture drop dur_c_s
	capture drop ghpi_cs_s
	
		egen sdvoly_r = std(lconstf)  if samplem==1 
		egen sdvoly_pr = std(plconstf)  if samplem==1  
		egen sdvoly = std(job_shock)  if samplem==1 
		egen rnw_s=std(rnw)  if samplem==1 
		egen dur_c_s=std(dur_c) if samplem==1
		egen ghpi_cs_s = std(ghpi_cs) if samplem==1
		egen afqtn_s=std(afqtn)  if samplem==1 
		label var sdvoly_r "Credit Access Risk"
		label var sdvoly_pr "Credit Access Risk"
		label var sdvoly "Job Shock"
		label var rnw_s "Net Worth"
		label var afqtn_s "AFQT Score"
		label var dur_c_s "Change in Unemployment Rate, County"
		label var ghpi_cs_s "HPI Growth Rate, County"

		
reg ps `controls0'   `controls15' `controls2' if samplem==1 , robust cluster(case)
est store y1

areg ps `controls0'   `controls15' `controls2'  if samplem==1 , absorb(state)   robust cluster(case)
est store y2

areg ps `controls0'  `controls3a' `controls15' `controls2' if samplem==1 , absorb(state)   robust cluster(case)
est store y2a

rename sdvoly_r sdvoly_r1
rename sdvoly_pr sdvoly_r 

reg ps `controls0'  `controls3a' `controls15' `controls2' if samplem==1 ,  vce(bootstrap, rep(1000))
est store y3

areg ps `controls0'   `controls15' `controls2'  if samplem==1 , absorb(state)  vce(bootstrap, rep(1000))  
est store y4

areg ps `controls0'  `controls3a' `controls15' `controls2'  if samplem==1 , absorb(state)  vce(bootstrap, rep(1000))  
est store y4a

rename sdvoly_r sdvoly_pr
rename sdvoly_r1 sdvoly_r

areg ps5001mb `controls0'  `controls3a' `controls15' `controls2'  if samplem==1 , absorb(state)  robust cluster(case)
est store y5

rename sdvoly_r sdvoly_r1
rename sdvoly_pr sdvoly_r 

areg ps5001mb `controls0'  `controls3a' `controls15' `controls2'  if samplem==1 , absorb(state)  vce(bootstrap, rep(1000))  
est store y6

areg ps5001mb `controls0'  `controls3a' `controls15' `controls2' if samplem==1 , absorb(state)  vce(bootstrap, rep(1000))  
est store y6a

#delimit ; 
estout   y2 y2a y4 y4a y5 y6a  using "table5.tex", replace  style(tex)   starlevels( * 0.1 ** 0.05 *** 0.01) 
cells(b(star fmt(%5.3fc)) se(par fmt(%5.3fc))) stats(N r2_a , fmt(%5.0fc %5.2f) labels("Observations" "Adj. R squared"))  varwidth(42) modelwidth(8)
mlabels((1) (2) (3) (4) (5) (6)) collabels(none)
varlabels(_cons "Constant" )  msign(--)    label 
order(sdvoly_r sdvoly dur_c_s ghpi_cs_s presentbias highdiscount  riskaverse afqtn_s   collegemore finqa finka rnw_s rnw_s ho_m ho_nom  w*debt  2008.year 2012.year)
keep(presentbias highdiscount  riskaverse afqtn_s   collegemore finqa finka sdvoly_r sdvoly rnw_s dur_c_s  ghpi_cs_s  ho_m ho_nom  w*debt 2008.year 2012.year)
prehead("\footnotesize {\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}  \vspace*{1ex} \begin{tabular}{l*{9}{c}} \toprule") 
	posthead("\midrule" " &\multicolumn{5}{c}{Baseline} && \multicolumn{3}{c}{Strict}\\"
"\cline{2-6} \cline{8-10}" "&\multicolumn{2}{c}{Original} && \multicolumn{2}{c}{Predicted} && Original && Predicted \\"
"\cline{2-3}  \cline{5-6} \cline{8-8} \cline{10-10}  \\")
	extracols(3 5 6)
prefoot("\addlinespace ") 
postfoot("\small{State Fixed Effects: }  & Yes & Yes & & Yes & Yes & & Yes && Yes \\" "\bottomrule " "\addlinespace " "\end{tabular}"
"\parbox[1]{6.5in}{\footnotesize {\em Notes:} The dependent variable is a dummy variable equal to one if the respondent is in 
the puzzle group, and zero if a saver. All regressions control for demographics (age, race, gender, marital status, 
and the number of children), and time and state fixed effects unless indicated.  For results using the original measure 
of credit access risk, robust standard errors clustered at individual level are reported in parentheses. 
For results using the predicted credit access risk measured, bootstrapped standard errors with 1000 replications, clustered at individual level, 
are reported in parentheses. The symbols ***(**)[*] indicate significance at the 1(5)[10] percent level.}}" )   ;	
#delimit cr



rename samplem msample
capture drop sample*

/// Table 7 Panel A (plus IntQ)
set more off
	capture drop sdvoly 
	capture drop sdvoly_r 
	capture drop sd_hd
	capture drop sd_ra
	capture drop sd_fl
	capture drop sd_iq
	capture drop rnw_s
	capture drop dur_c_s 
	capture drop ghpi_cs_s
	capture drop afqtn_s
	
		egen sdvoly_r = std(plconstf) if msample==1
		egen sdvoly = std(job_shock) if msample==1
		egen rnw_s=std(rnw)
		egen dur_c_s=std(dur_c)
		egen ghpi_cs_s=std(ghpi_cs)
		egen afqtn_s =std(afqtn)
		
		label var afqtn_s "AFQT Score"
		label var sdvoly "Job Shock"
		label var rnw_s "Net Wealth"
		label var dur_c_s "Change in Unemployment Rate, County"
		label var ghpi_cs_s "HPI Growth Rate, County"
		label var interestq_c "Int.Rate Q."
		label var sdvoly_r "Predicted Credit Access Risk"
		label var sdvoly "Job Shock"

		gen sd_fl=sdvoly_r*finqa
		gen sd_iq=sdvoly_r*interestq_c
		
		label var sd_fl "Credit Risk $\times$ Fin. Literacy"
		label var sd_iq "Predicted Credit Risk $\times$ Int.Rate Q."


local controls0 "i.age presentbias highdiscount riskaverse b1.gender b3.race i.year married haskids afqtn_s  collegemore finka"
local controls1 "finqa "
local controls1a "interestq_c "
local controls3 "rnw_s ho_* w*debt"
local controls2 "sdvoly dur_c_s ghpi_cs_s"
local controls15 "sdvoly_r"

set seed 1000

est clear

qui: reg ps `controls0'  `controls3' `controls15' `controls2' `controls1' i.state [pw=weight] if msample==1
gen sample=e(sample)

reg ps `controls0' `controls15' `controls2' `controls1'  sd_fl if  sample==1, vce(bootstrap, rep(1000)) 
est store y1a  

reg ps `controls0'  `controls3' `controls15' `controls2' `controls1'  sd_fl if sample==1, vce(bootstrap, rep(1000)) 
est store y3a

areg ps `controls0'  `controls3' `controls15' `controls2' `controls1'  sd_fl if sample==1 & sd_iq!=., absorb(state) vce(bootstrap, rep(1000)) 
est store y4a

areg ps `controls0'  `controls3' `controls15' `controls2' `controls1a'  sd_iq  if sample==1, absorb(state) vce(bootstrap, rep(1000)) 
est store y5a

areg ps5001mb `controls0'  `controls3' `controls15' `controls2' `controls1' sd_fl if sample==1 & sd_iq!=., absorb(state) vce(bootstrap, rep(1000)) 
est store y6a

areg ps5001mb `controls0'  `controls3' `controls15' `controls2' `controls1a' sd_iq  if sample==1, absorb(state) vce(bootstrap, rep(1000)) 
est store y7a

drop sample

#delimit ; 
estout  y1a y3a y4a y6a using "table7a.tex", replace  style(tex)   starlevels( * 0.1 ** 0.05 *** 0.01) 
cells(b(star fmt(%5.3fc)) se(par fmt(%5.3fc))) stats(N r2 , fmt(%5.0fc %5.2f) labels("Observations" "R squared"))  varwidth(42) modelwidth(8)
mlabels((1) (2) (3) (4)) collabels(none)
varlabels(_cons "Constant" )
msign(--)    label 
order(sdvoly_r sdvoly finqa sd_fl)
keep(sdvoly_r sdvoly finqa sd_fl)
prehead("\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}  \vspace*{1ex} \begin{tabular}{l*{5}{c}} \toprule") 
	posthead("\midrule" "  &\multicolumn{3}{c}{Baseline} && Strict\\ " "\cline{2-4} \cline{6-6}  \\")
	extracols(4)
prefoot("\addlinespace ") 
postfoot("\small{Financial Controls: }  & No & Yes & Yes && Yes  \\" "\small{State Fixed Effects: }  & No & No & Yes && Yes  \\"  "\bottomrule " "\addlinespace " "\end{tabular}" )   ;	
#delimit cr



#delimit ; 
estout  y4a y5a y6a y7a using "table7aextra.tex", replace  style(tex)   starlevels( * 0.1 ** 0.05 *** 0.01) 
cells(b(star fmt(%5.3fc)) se(par fmt(%5.3fc))) stats(N r2 , fmt(%5.0fc %5.2f) labels("Observations" "R squared"))  varwidth(42) modelwidth(8)
mlabels((1) (2) (3) (4)) collabels(none)
varlabels(_cons "Constant" )
msign(--)    label 
order(sdvoly_r sdvoly finqa interestq_c sd_fl sd_iq)
keep(sdvoly_r sdvoly finqa interestq_c sd_fl sd_iq)
prehead("\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}  \vspace*{1ex} \begin{tabular}{l*{5}{c}} \toprule") 
	posthead("\midrule" "  &\multicolumn{2}{c}{Baseline} && \multicolumn{2}{c}{Strict}\\ " "\cline{2-3} \cline{5-6}  \\")
	extracols(3)
prefoot("\addlinespace ") 
postfoot("\small{Financial Controls: } & Yes & Yes && Yes & Yes  \\" "\small{State Fixed Effects: } & Yes & Yes && Yes & Yes   \\"  "\bottomrule " "\addlinespace " "\end{tabular}")   ;	
#delimit cr


/// Table 7, panel B

sort case year
bys case: gen f4sdvoly_r=f4.sdvoly_r
bys case: gen f4sdvoly=f4.sdvoly

*hgc_s 
local controls0 "i.age presentbias highdiscount riskaverse b1.gender b3.race i.year married haskids afqtn_s  collegemore finqa finka"
local controls3 " rnw1 ho_* w*debt"
local controls15 "f4sdvoly_r f4sdvoly dur_c_s ghpi_cs_s"


est clear

reghdfe ps `controls0'  `controls3' `controls15' if msample==1  [pw=weight] , cluster(case) absorb(state age)  keepsingletons 
gen sample=e(sample)

reg ps `controls0' `controls15'    if  sample==1, vce(bootstrap, rep(1000)) 
est store y1  

reg ps `controls0' `controls15'  `controls3' if sample==1, vce(bootstrap, rep(1000)) 
est store y2

areg ps `controls0' `controls15'  `controls3' if sample==1, absorb(state) vce(bootstrap, rep(1000))  
est store y3 

areg ps5001mb `controls0' `controls15'  `controls3' if sample==1, absorb(state) vce(bootstrap, rep(1000)) 
est store y4


drop sample


#delimit ; 
estout  y1 y2 y3 y4  using "table7b.tex", replace  style(tex)   starlevels( * 0.1 ** 0.05 *** 0.01) 
cells(b(star fmt(%5.3fc)) se(par fmt(%5.3fc))) stats(N r2 , fmt(%5.0fc %5.2f) labels("Observations" "R squared"))  varwidth(42) modelwidth(8)
mlabels((1) (2) (3) (4)) collabels(none)
varlabels(_cons "Constant" f4sdvoly_r "F4: Predicted Credit Access Risk" f4sdvoly "F4: Job Shock")
msign(--)    label 
order(f4sdvoly_r f4sdvoly)
keep(f4sdvoly_r f4sdvoly)
prehead("\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}  \vspace*{1ex} \begin{tabular}{l*{5}{c}} \toprule") 
	posthead("\midrule" "  &\multicolumn{3}{c}{Baseline} && Strict\\ " "\cline{2-4} \cline{6-6}  \\")
	extracols(4)
prefoot("\addlinespace ") 
postfoot("\small{Financial Controls: } & Yes & Yes & Yes && Yes  \\" "\small{State Fixed Effects: } & Yes & Yes & Yes && Yes   \\"  "\bottomrule " "\addlinespace " "\end{tabular}")   ;	
#delimit cr



////////////////Table 7, Panel C: FIXED EFFECTS

est clear

set more off

	capture drop sdvoly 
	capture drop sdvoly_r 
	capture drop sd_fk
	capture drop sd_edu
	capture drop sd_fl
	capture drop sd_sy
	
		egen sdvoly_r = std(plconstf_fe)
		egen sdvoly = std(job_shock)
		label var sdvoly_r "Predicted Credit Access Risk"
		label var sdvoly "Job Shock"

		gen sd_fk=sdvoly_r*finknowledge 
		gen sd_edu=sdvoly_r*hgc
		gen sd_fl=sdvoly_r*totalfinq
		gen sd_sy =sdvoly_r*sdvoly
		
		label var sd_fk "Predicted Risk $\times$ Fin. Self-Knowledge"
		label var sd_edu "Predicted Risk $\times$ Education"
		label var sd_fl "Predicted Risk $\times$ Fin. Literacy"
		label var sd_sy "Predicted Risk $\times$ Job Shock"
local controls0 "i.age i.year married haskids"
local controls3 " rnw_s ho_* w*debt"
local controls2 "sdvoly dur_c_s ghpi_cs_s"
local controls15 "sdvoly_r"

est clear

xtreg ps `controls0' `controls2' `controls15' if msample==1, fe vce(bootstrap, rep(1000)) 
est store y1

xtreg ps `controls0' `controls2' `controls15' `controls3' if msample==1, fe vce(bootstrap, rep(1000))    
est store y2

reghdfe ps `controls0' `controls2' `controls15'  `controls3' if msample==1, cluster(case) absorb(case state)  keepsingletons 
est store y3

reghdfe ps `controls0' `controls2' `controls15'  `controls3' sd_fl sd_sy if msample==1, cluster(case) absorb(case state)  keepsingletons 
est store y3a

reghdfe ps `controls0' `controls2' `controls15'  `controls3' sd_fk sd_sy if msample==1, cluster(case) absorb(case state)  keepsingletons 
est store y3b

reghdfe ps `controls0' `controls2' `controls15'  `controls3' sd_edu sd_sy if msample==1, cluster(case) absorb(case state)  keepsingletons 
est store y3c

reghdfe ps5001mb `controls0' `controls2' `controls15' `controls3' if msample==1, cluster(case) absorb(case state)  keepsingletons 
est store y4

reghdfe ps5001mb `controls0' `controls2' `controls15' `controls3' sd_fl sd_sy if msample==1, cluster(case) absorb(case state)  keepsingletons 
est store y4a

reghdfe ps5001mb `controls0' `controls2' `controls15' `controls3' sd_fk  sd_sy if msample==1, cluster(case) absorb(case state)  keepsingletons 
est store y4b

reghdfe ps5001mb `controls0' `controls2' `controls15' `controls3' sd_edu sd_sy if msample==1, cluster(case) absorb(case state)  keepsingletons 
est store y4c


#delimit ; 
estout  y1 y2 y3 y4  using "table7c.tex", replace  style(tex)   starlevels( * 0.1 ** 0.05 *** 0.01) 
cells(b(star fmt(%5.3fc)) se(par fmt(%5.3fc))) stats(N r2_within , fmt(%5.0fc %5.2f) labels("Observations" "Within R squared"))  varwidth(42) modelwidth(8)
mlabels((1) (2) (3) (4)) collabels(none)
varlabels(_cons "Constant" )  msign(--)    label 
order(sdvoly_r sdvoly)
keep(sdvoly_r sdvoly)
prehead("\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}  \vspace*{1ex} \begin{tabular}{l*{5}{c}} \toprule") 
	posthead("\midrule" "  &\multicolumn{3}{c}{Baseline} && \multicolumn{1}{c}{Strict}\\ " "\cline{2-4} \cline{6-6}  \\")
	extracols(4)
prefoot("\addlinespace ") 
postfoot(" \small{Financial Controls: } & No & Yes & Yes && Yes \\ \small{State Fixed Effects: } & No & No & Yes && Yes  \\ \small{Individual Fixed Effects: } & Yes & Yes & Yes && Yes \\" "\bottomrule " "\addlinespace " "\end{tabular}"
"\parbox[1]{6.0in}{\footnotesize {\em Notes:} The dependent variable is a dummy variable equal to one if the respondent is in the puzzle group and zero if a saver.
F4 is a four-period forward operator. All regressions include controls as in Table 5. Bootstraped standard errors with 1000 repetitions  
(in parentheses) clustered at the individual level. The symbols ***(**)[*] indicate significance at the 1(5)[10] percent level.}" )   ;	
#delimit cr



#delimit ; 
estout  y3a y3b y3c y4a y4b y4c using "table7c_int.tex", replace  style(tex)   starlevels( * 0.1 ** 0.05 *** 0.01) 
cells(b(star fmt(%5.3fc)) se(par fmt(%5.3fc))) stats(N r2 , fmt(%5.0fc %5.2f) labels("Observations" "Within R squared"))  varwidth(42) modelwidth(8)
mlabels((1) (2) (3) (4) (5) (6) ) collabels(none)
varlabels(_cons "Constant" )  msign(--)    label 
order(sdvoly_r sdvoly sd_fl sd_fk sd_edu sd_sy)
keep(sdvoly_r sdvoly sd_fl sd_fk sd_edu sd_sy)
prehead("\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}  \vspace*{1ex} \begin{tabular}{l*{7}{c}} \toprule") 
	posthead("\midrule" "  &\multicolumn{3}{c}{Baseline} && \multicolumn{3}{c}{Strict}\\ " "\cline{2-4} \cline{6-7}  \\")
	extracols(4)
prefoot("\addlinespace ") 
postfoot("\small{Individual Fixed Effects: } & Yes & Yes & Yes && Yes & Yes & Yes \\ \small{Financial Controls: } & Yes & Yes & Yes && Yes & Yes & Yes \\ \small{State Fixed Effects: } & Yes & Yes & Yes && Yes & Yes & Yes   \\" "\bottomrule " "\addlinespace " "\end{tabular}"
"\parbox[1]{6.0in}{\footnotesize {\em Notes:} The dependent variable is a dummy variable equal to one if the respondent is in the puzzle group and zero if a saver.
Bootstraped standard errors with 1000 repetitions  (in parentheses) are clustered at the individual level. The symbols ***(**)[*] indicate significance at the 1(5)[10] percent level.}" )   ;	
#delimit cr



/// Transitions Table 8

tsset case year
sort case year
gen dlconst=plconstf - l4.plconstf
gen dshock=job_shock - l4.job_shock 
capture drop drnw
gen drnw=rnw-l4.rnw if !mi(rnw, l4.rnw)  // 1 if became positive, 0 if not change, -1 if became negative

egen drnw_s=std(drnw)
gen dhowner=howner-l4.howner if !mi(howner, l4.howner)  // 1 if became home owner 0 if no change -1 if sold house and renting now

foreach i in wcardebt wmortgdebt wstuddebt {
	gen d`i'=`i'-l4.`i' if !mi(`i', l4.`i')
	// to make it go in the same direction, i.e. 1 now means reduction in financial debt
	*replace d`i'=-1*d`i'
}

gen l4rnw = l4.rnw_s
gen l4ho_m=l4.ho_m 
gen l4ho_nom=l4.ho_nom
gen l4wcardebt =l4.wcardebt
gen l4wstuddebt =l4.wstuddebt

capture drop sdvoly_r 
capture drop sdvoly 
capture drop sd_fl
capture drop sd_fk



preserve
keep if msample==1

egen sdvoly_r = std(dlconst)
label var sdvoly_r "Change in Predicted Credit Access Risk"
egen sdvoly = std(dshock)
label var sdvoly "Change in Job Shock"

gen sd_fl=sdvoly_r*finqa 
gen sd_fk=sdvoly_r*finka 
label var sd_fl "Pr. Risk $\times$ Fin. Literacy"
label var sd_fk "Pr. Risk $\times$ Fin. Self-Knowledge"

local controls0 "i.age presentbias highdiscount riskaverse b1.gender b3.race married haskids afqtn_s  collegemore finqa finka"
local controls3 " l4rnw l4ho_m l4ho_nom l4w*debt"
local controls15 "sdvoly_r sdvoly dur_c_s ghpi_cs_s"

est clear

tsset case year

areg p_s_vp `controls0' `controls3'  `controls15' b2008.year if year>2004 & msample==1, absorb(state)  vce(bootstrap, rep(1000)) 
est store y1
areg p_s_vp `controls0' `controls3'  `controls15' sd_fl sd_fk b2008.year if year>2004  & msample==1, absorb(state)  vce(bootstrap, rep(1000)) 
est store y1a
areg p_s_vp500 `controls0'  `controls3' `controls15' b2008.year  if year>2004  & msample==1, absorb(state)  vce(bootstrap, rep(1000))  
est store y2
areg p_s_vp500 `controls0'  `controls3' `controls15' sd_fl sd_fk  b2008.year  if year>2004  & msample==1, absorb(state)  vce(bootstrap, rep(1000))  
est store y2a

areg s_p_vs `controls0' `controls3'  `controls15' b2008.year  if year>2004  & msample==1, absorb(state)  vce(bootstrap, rep(1000)) 
est store y3
areg s_p_vs `controls0' `controls3'  `controls15' sd_fl sd_fk  b2008.year  if year>2004  & msample==1, absorb(state)  vce(bootstrap, rep(1000))   
est store y3a
areg s_p_vs500 `controls0'  `controls3' `controls15' b2008.year  if year>2004  & msample==1, absorb(state)  vce(bootstrap, rep(1000)) 
est store y4
areg s_p_vs500 `controls0'  `controls3' `controls15' sd_fl sd_fk  b2008.year  if year>2004  & msample==1, absorb(state)  vce(bootstrap, rep(1000))  
est store y4a


#delimit ; 
estout  y1 y2 y3 y4 using "table8.tex", replace  style(tex)   starlevels( * 0.1 ** 0.05 *** 0.01) 
cells(b(star fmt(%5.3fc)) se(par fmt(%5.3fc))) stats(N r2 , fmt(%5.0fc %5.2f) labels("Observations" "R squared"))  varwidth(42) modelwidth(8)
mlabels((1) (2) (3) (4) ) collabels(none)
extracols(3)
varlabels(_cons "Constant" l4rnw "L4: Net Worth" l4ho_m "L4: Homeowner, with Mortgage" l4ho_nom "L4: Homeowner, No Mortgage" l4wcardebt "L4: Has Car Loan" l4wstuddebt "L4: Has Student Debt")
msign(--)    label 
order(sdvoly_r sdvoly dur_c_s ghpi_cs_s presentbias highdiscount  riskaverse finqa finka sdvoly_r sdvoly sd_fl l4rnw l4ho_m l4ho_nom l4w*debt  2012.year)
keep(sdvoly_r sdvoly dur_c_s ghpi_cs_s  presentbias highdiscount  riskaverse finqa finka  l4rnw l4ho_m  l4ho_nom  l4w*debt   2012.year)
prehead("\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}  \vspace*{1ex} \begin{tabular}{l*{5}{c}} \toprule") 
posthead("\midrule" "  &\multicolumn{2}{c}{P $\rightarrow$ S} && \multicolumn{2}{c}{S $\rightarrow$ P}\\ " 	
	"& Baseline & Strict &&  Baseline & Strict \\" "\cline{2-3} \cline{5-6}\\")
prefoot("\addlinespace ") 
postfoot("\bottomrule " "\end{tabular}" 
"\parbox[1]{6.0in}{\footnotesize {\em Notes:} The dependent variable is a dummy variable equal to one if the transition from puzzle to saver, $\boldsymbol{P \rightarrow S}$ 
(or from saver to puzzle $\boldsymbol{S \rightarrow P}$ ) occurred, and zero if the respondent remained in the puzzle (or the saver) category. 
All regressions also control for formal knowledge (years of completed education and AFQT scores); 
demographics (age, race, gender, marital status, and the number of children); and state fixed effects.
Bootstrapped standard errors with 1000 repetitions (in parentheses) are clustered at the individual level. The symbols ***(**)[*] indicate significance at the 1(5)[10] percent level.}" )   ;	

#delimit cr

#delimit ; 
estout  y1a y2a y3a y4a using "table8int.tex", replace  style(tex)   starlevels( * 0.1 ** 0.05 *** 0.01) 
cells(b(star fmt(%5.3fc)) se(par fmt(%5.3fc))) stats(N r2 , fmt(%5.0f %5.2f) labels("Observations" "R squared"))  varwidth(42) modelwidth(8)
mlabels((1) (2) (3) (4) ) collabels(none)
extracols(3)
varlabels(_cons "Constant" )
msign(--)    label 
order(finqa finka sdvoly_r sdvoly sd_fl sd_fk ) keep(finqa finka sdvoly_r sdvoly sd_fl sd_fk )
prehead("\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}  \vspace*{1ex} \begin{tabular}{l*{5}{c}} \toprule") 
posthead("\midrule" "  &\multicolumn{2}{c}{P $\rightarrow$ S} && \multicolumn{2}{c}{S $\rightarrow$ P}\\ " 	
	" & Baseline & Strict &&  Baseline & Strict \\" "\cline{2-3} \cline{4-6}\\")
prefoot("\addlinespace ") 
postfoot("\bottomrule " "\addlinespace " "\end{tabular}" 
"\parbox[1]{6.0in}{\footnotesize {\em Notes:} The dependent variable is a dummy variable equal to one if the transition from puzzle to saver, $\boldsymbol{P \rightarrow S}$ 
(or from saver to puzzle $\boldsymbol{S \rightarrow P}$ ) occurred, and zero if the respondent remained in the puzzle (or the saver) category. 
All regressions control for formal knowledge (years of completed education and AFQT scores); 
demographics (age, race, gender, marital status, and the number of children); and State Fixed Effects.
Bootstrapped standard errors with 1000 repetitions (in parentheses) are clustered at the individual level. The symbols ***(**)[*] indicate significance at the 1(5)[10] percent level.}" )   ;	

#delimit cr
restore




********* APENDIX Table Multinomial Logits: Puzzle vs. Others
gen samplemm=msample
replace samplemm=1 if group_a==2 
replace samplemm=1 if group_a==3

do "C:\Users\olgag\Dropbox\Research_Maria\Credit Card Debt Puzzle\NLSY79 Data\Programsoct15\predicting_lconstf_all.do"

capture drop sdvoly_pr
capture drop sdvoly
capture drop rnw_s
capture drop dur_c_s
capture drop ghpi_cs_s

egen sdvoly_pr=std(plconstf_all) if sampleaa==1 
egen sdvoly=std(job_shock) if sampleaa==1
egen rnw_s=std(rnw) if sampleaa==1
egen dur_c_s=std(dur_c) if sampleaa==1
egen ghpi_cs_s=std(ghpi_cs) if sampleaa==1

label var sdvoly_pr "Predicted Credit Access Risk"
label var sdvoly "Job Shock"
label var rnw_s "Net Wealth"
label var dur_c_s "Change in Unemployment Rate, County"
label var ghpi_cs_s "HPI Growth Rate, County"

local controls0 "i.age presentbias highdiscount riskaverse b1.gender b3.race i.year married haskids afqtn_s  collegemore finqa finka"
local controls3 " rnw_s ho_* w*debt"
local controls2 "sdvoly dur_c_s ghpi_cs_s"
local controls15 "sdvoly_r"
local controls15p "sdvoly_pr"

mlogit group_a `controls0'  `controls3' `controls15p' `controls2'  if samplemm==1, rrr base(1)  vce(bootstrap, rep(1000))
esttab using "groups.tex", replace unstack se margin wrap nomtitles label nobaselevels msign(--) cells(b(star fmt(%5.3fc)) se(par fmt(%5.3fc))) 


mlogit group_a5001mb `controls0'  `controls3' `controls15p' `controls2'  if samplemm==1, rrr base(1)  vce(bootstrap, rep(1000))
esttab using "groups500.tex", replace unstack se margin wrap nomtitles label nobaselevels msign(--) cells(b(star fmt(%5.3fc)) se(par fmt(%5.3fc))) 


///////////////////////////////////////////////////////

preserve

capture drop dlconst
capture drop sdvoly_r
capture drop sdvoly
capture drop dshock
 
tsset case year
sort case year
gen dlconst=plconstf_all - l4.plconstf_all
gen dshock=job_shock-l4.job_shock

keep if sampleaa==1 & dlconst!=. & dshock!=. & p_tr500!=.
keep if year>2004

capture drop sdvoly_r
capture drop sdvoly
capture drop rnw_s
capture drop dur_c_s
capture drop ghpi_cs_s

egen sdvoly_r=std(plconstf_all)  
egen sdvoly=std(job_shock) 
egen l4rnw_s=std(l4rnw) 
egen dur_c_s=std(dur_c)
egen ghpi_cs_s=std(ghpi_cs)


label var sdvoly_r "Change in Predicted Credit Access Risk"
label var sdvoly "Change in Job Shock"
label var l4ho_m "L4: Homeowner, with Mortgage"
label var l4ho_nom "L4: Homeowner, No Mortgage"
label var l4wcardebt "L4: Has Car Loan"
label var l4wstuddebt "L4: Has Student Debt"
label var l4rnw_s "L4: Net Worth"
label var dur_c_s "Change in Unemployment Rate, County"
label var ghpi_cs_s "HPI Growth Rate, County"

local controls0 "age presentbias highdiscount riskaverse married haskids afqtn_s  collegemore finqa finka"
local controls3 " l4rnw_s l4ho_m l4ho_nom l4w*debt"
local controls15 "sdvoly_r sdvoly dur_c_s ghpi_cs_s"
su p_tr500 `controls0'  `controls3' `controls15' b2008.year if p_tr500!=. 

mlogit p_tr500 `controls0'  `controls3' `controls15' b2008.year, rrr  vce(bootstrap, rep(1000))
esttab using "tr_p500n.tex", replace unstack se margin wrap nomtitles label nobaselevels msign(--) cells(b(star fmt(%5.3fc)) se(par fmt(%5.3fc))) 

restore

preserve

capture drop dlconst
capture drop sdvoly_r
capture drop sdvoly
capture drop dshock
 
tsset case year
sort case year
gen dlconst=plconstf_all - l4.plconstf_all
gen dshock=job_shock-l4.job_shock

keep if sampleaa==1 & dlconst!=. & dshock!=. & s_tr500!=.
keep if year>2004

capture drop sdvoly_r
capture drop sdvoly
capture drop rnw_s
capture drop dur_c_s
capture drop ghpi_cs_s

egen sdvoly_r=std(plconstf_all)  
egen sdvoly=std(job_shock) 
egen l4rnw_s=std(l4rnw) 
egen dur_c_s=std(dur_c)
egen ghpi_cs_s=std(ghpi_cs)


label var sdvoly_r "Change in Predicted Credit Access Risk"
label var sdvoly "Change in Job Shock"
label var l4ho_m "L4: Homeowner, with Mortgage"
label var l4ho_nom "L4: Homeowner, No Mortgage"
label var l4wcardebt "L4: Has Car Loan"
label var l4wstuddebt "L4: Has Student Debt"
label var l4rnw_s "L4: Net Worth"
label var dur_c_s "Change in Unemployment Rate, County"
label var ghpi_cs_s "HPI Growth Rate, County"

local controls0 "age presentbias highdiscount riskaverse married haskids afqtn_s  collegemore finqa finka"
local controls3 " l4rnw_s l4ho_m l4ho_nom l4w*debt"
local controls15 "sdvoly_r sdvoly dur_c_s ghpi_cs_s"
su s_tr500 `controls0'  `controls3' `controls15' b2008.year if s_tr500!=. 

mlogit s_tr500 `controls0'  `controls3' `controls15' b2008.year, rrr vce(bootstrap, rep(1000))
esttab using "tr_s500n.tex", replace unstack se margin wrap nomtitles label nobaselevels msign(--) cells(b(star fmt(%5.3fc)) se(par fmt(%5.3fc))) 

restore
